package API.DAY9.thread;

public class SyncAPIDemo1 {
    public static void main(String[] args) {
//        StringBuilder stringBuilder = new StringBuilder();
        StringBuffer stringBuilder = new StringBuffer();
        Thread t1 = new Thread(){
            public void run(){
                for (int i = 0; i < 1000; i++) {
                    stringBuilder.append("a");
                }
            }
        };
        Thread t2 = new Thread(){
            public void run(){
                for (int i = 0; i < 1000; i++) {
                    stringBuilder.append("b");
                }
            }
        };
        t1.start();
        t2.start();
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(stringBuilder.length());
    }
}
